package com.pds.web.spotCheck.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.spotCheck.entity.PdsEnvironmentImprove;
import com.pds.web.spotCheck.service.PdsEnvironmentImproveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 监管部门整改机构表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-02-02
 */
@RestController
@RequestMapping("/environmentImprove")
@Api(tags="监管部门整改机构表")
public class PdsEnvironmentImproveController extends BaseController {
    @Resource
    private PdsEnvironmentImproveService pdsEnvironmentImproveService;

    /**
     * 分页查询整改记录
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询整改记录")
    @GetMapping("/page")
    public TableDataInfo pageEnvironmentImprove(PdsEnvironmentImprove pdsEnvironmentImprove){
        startPage();
        List<PdsEnvironmentImprove> list = pdsEnvironmentImproveService.selectList(pdsEnvironmentImprove);
        return getDataTable(list);
    }

    /**
     * 查询整改列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询整改列表")
    @GetMapping("/list")
    public R<List<PdsEnvironmentImprove>> listEnvironmentImprove(PdsEnvironmentImprove pdsEnvironmentImprove){
        List<PdsEnvironmentImprove> list = pdsEnvironmentImproveService.selectList(pdsEnvironmentImprove);
        return R.ok(list);
    }

    /**
     * 根据ID查询整改记录
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("整改详情")
    @GetMapping("/queryById/{id}")
    public R<PdsEnvironmentImprove> queryEnvironmentImproveById(@PathVariable("id")Long id) {
        return R.ok(pdsEnvironmentImproveService.queryById(id));
    }

    /**
     * 创建整改记录
     * @param pdsEnvironmentImprove 记录
     * @return 整改记录
     */
    @ApiOperation("创建整改记录")
    @PostMapping("/add")
    public R<PdsEnvironmentImprove> addEnvironmentImprove(@RequestBody PdsEnvironmentImprove pdsEnvironmentImprove){
        return R.ok(pdsEnvironmentImproveService.insert(pdsEnvironmentImprove));
    }

    /**
     * 修改整改记录
     * @param pdsEnvironmentImprove 记录
     * @return 成功标识
     */
    @ApiOperation("修改整改记录")
    @PutMapping("/edit")
    public R<Boolean> editEnvironmentImprove(@RequestBody PdsEnvironmentImprove pdsEnvironmentImprove){
        return R.ok(pdsEnvironmentImproveService.update(pdsEnvironmentImprove));
    }

    /**
     * 根据ID删除整改记录
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除整改记录")
    @DeleteMapping("/delete")
    public R<Boolean> deleteEnvironmentImproveById(@RequestParam Long id) {
        return R.ok(pdsEnvironmentImproveService.deleteById(id));
    }

}